import re
import shutil
import os
import pprint
import json
from moviepy import AudioFileClip




def get_audio_duration(file_path):
    """获取音频文件的时长"""
    audio = AudioFileClip(file_path)
    duration = audio.duration
    audio.close()
    return duration
def natural_sort_key(s):
    """提供用于自然排序的键函数"""
    return [int(text) if text.isdigit() else text.lower() for text in re.split(r'(\d+)', s)]
def load_config():
    with open('config.json', 'r', encoding='utf-8') as f:
        config = json.load(f)
    return config
config = load_config()
pprint.pprint(config)
def get_folder_path():
    workspace_path = os.path.abspath(os.path.join(os.getcwd(), ".."))
    folder_name = config['folder_name']
    return f'{workspace_path}/{folder_name}'
folder_path = get_folder_path()
audio_path = f'{folder_path}/audio'
txt_name = config['txt_name']
file_full_path = f'{folder_path}/{txt_name}.txt'
print(file_full_path)

